<?php
namespace RSP\UserBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;

class RegistrationFormType extends BaseType {

    private $class;

    /**
     * @param string $class The User class name
     */
    public function __construct($class) {
        $this->class = $class;
    }

    public function buildForm(FormBuilderInterface $builder, array $options) {
        parent::buildForm($builder, $options);
        $builder->add('nom', 'text')
                ->add('prenom', 'text')
                ->add('captcha', 'captcha', array(
        'width' => 200,
        'height' => 50,
        'length' => 6,
    ))
                ->add('email', 'email')
               
                ->add('adresse', 'text')
                ->add('pays')
                ->add('ville')
                ->add('usersecoles','collection',array(
                    'type'=> new \RSP\UserBundle\Form\UserEcoleType(),
                    'allow_add'    => true,
                    'allow_delete' => true
                ))
                ->add('usersuniversites','collection',array(
                    'type'=> new \RSP\UserBundle\Form\UserUniversiteType(),
                    'allow_add'    => true,
                    'allow_delete' => true
                ))
                ->add('plainPassword', 'repeated', array(
                'type' => 'password',
                'options' => array('translation_domain' => 'FOSUserBundle'),
                'first_options' => array('label' => 'form.password'),
                'second_options' => array('label' => 'form.password_confirmation'),
                'invalid_message' => 'fos_user.password.mismatch',
            ))
                ->add('remarques', 'textarea')
                ->add('type', 'choice', array(
    'choices' => array('entreprise' => 'Entreprise', 'etudiant(e)' => 'Etudiant(e)', 'employé(e)' => 'Employé(e)','autre'=>"Autre")))
                ->add('date', 'date', array(
    'widget' => 'single_text',
    'format' => 'dd-MM-yyyy'))
                ->add('telephone', 'text')
                ->add('sex', 'choice', array(
    'choices' => array('m' => 'Masculin', 'f' => 'Féminin')
)); 
            
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => $this->class,
            'intention' => 'registration',
        ));
    }

    public function getName() {
        return 'rsp_user_registration';
    }

}
